package gpl.pierrick.brihaye.aramorph.solr;

import java.util.Map;

import gpl.pierrick.brihaye.aramorph.AraMorph;
import gpl.pierrick.brihaye.aramorph.lucene.ArabicStemmer;

import org.apache.lucene.analysis.TokenStream;
import org.apache.solr.analysis.BaseTokenFilterFactory;

public class ArabicStemmerFactory extends BaseTokenFilterFactory {

	private boolean normalize;
	private boolean useJDBC;
	
	@Override
	public TokenStream create(TokenStream input) {
		return new ArabicStemmer(input, AraMorph.getDefault(normalize, useJDBC));
	}

	@Override
	public void init(Map<String, String> args) {
		super.init(args);
		useJDBC = getBoolean("useJDBC", false);
		normalize = getBoolean("normalize", true);
	}

}
